/***************************************************************************
 *   Copyright (C) 2007 by saa   *
 *   root@saa   *
 ***************************************************************************/
 
#include "telnetthread.h"
#include "telnetclient.h"
#include "compilemode.h"

void TelnetThread::run()
{
    TelnetClient * telnetClient(new TelnetClient());

    connect(telnetClient, SIGNAL(saveResults(const LinkList &)), parent(), SLOT(saveLinkList(const LinkList & )), Qt::QueuedConnection);
    connect(telnetClient, SIGNAL(ready(QObject *)), parent(), SLOT(telnetClientFinished(QObject * )), Qt::QueuedConnection);
    connect(telnetClient, SIGNAL(tracerouteToTargetStarted(const QString &, const QString &)),\
            parent(), SLOT(tracerouteToTargetStarted(const QString &, const QString &)), Qt::QueuedConnection);
    connect(telnetClient, SIGNAL(tracerouteToTargetFinished(const QString &, const QString &)),\
            parent(), SLOT(tracerouteToTargetFinished(const QString &, const QString & )), Qt::QueuedConnection);
    connect(telnetClient, SIGNAL(logTelnetMessage(const QString &, const LogFlag::LogLevels)), \
            parent(), SLOT(log(const QString &, const LogFlag::LogLevels)), Qt::QueuedConnection);

    telnetClient->setTelnetParams(m_routeServer);
    telnetClient->setTargetList(m_targetList);

    telnetClient->run();
#ifndef ONE_THREAD
    QThread::exec();
#endif    
}

void TelnetThread::quit()
{
    QThread::quit();
}
